/*
 * @Descripttion:
 * @version:
 * @Author: gengzhi
 * @Date: 2020-08-17 11:33:35
 * @LastEditors: gengzhi
 * @LastEditTime: 2020-08-18 15:36:42
 */
package tokens

import (
	"time"

	infra "kendoDDD/ddd_infrastructure"

	"github.com/google/uuid"
)

// Tokens aggregate root
type Tokens struct {
}

//CreatToken 创建长连接Token，并缓存。
func (p *Tokens) CreatToken(userID string) (token string, err error) {
	token = uuid.New().String()
	err = infra.MemoryCache.Put(userID, token, 5*time.Minute)
	return
}

// New creates
func New() *Tokens {
	return &Tokens{}
}
